package com.gzx.plugin.tjzy.modular.gzxcase.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gzx.plugin.tjzy.modular.gzxcase.entity.GzxWckjOverdue;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author zjt
 * @description
 * @since 2025/3/27 15:14
 */
public interface GzxWckjOverdueMapper extends BaseMapper<GzxWckjOverdue> {

    @Insert("<script>" +
            "INSERT INTO gzx_wckj_overdue (batch_number, user_id, overdue_amount) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.batchNumber}, #{item.userId}, #{item.overdueAmount})" +
            "</foreach>" +
            "</script>")
    void insertOverdue(List<GzxWckjOverdue> wckjOverdueList);

    @Update("<script>" +
            "update gzx_wckj_overdue a " +
            "left join gzx_case b on b.debtor_card_id = a.user_id and a.batch_number = b.batch_number " +
            "set b.overdue_amount = a.overdue_amount , b.clean_loan_amount = a.overdue_amount " +
            "WHERE b.batch_number = #{batchNumber}" +
            "</script>")
    void modifyCaseOverdueAmount(String batchNumber);
}
